package com.loukou.lkt.web.processor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.loukou.lkt.lkt.bo.GoodsBo;
import com.loukou.lkt.lkt.bo.PageList;
import com.loukou.lkt.lkt.entity.Goods;
import com.loukou.lkt.lkt.resp.RespDto;
import com.loukou.lkt.lkt.service.GoodsService;

@Service
public class SelectGoodsProcessor {
	@Autowired
	private GoodsService goodsService;
    
	public RespDto<PageList<GoodsBo>> getSelectGoods(int warehouseId, int positionType, String sku,
			String barcode, String goodsName,int pageIndex,int pageSize){
		return goodsService.goodsPageList(warehouseId, positionType, sku, barcode, goodsName, pageIndex, pageSize);
	}
	
	public RespDto<GoodsBo> getOneGoods(int warehouseId, int positionType, String sku){
		RespDto<GoodsBo> resp = new RespDto<GoodsBo>();
		Goods goods= goodsService.getGoods(sku);
		if(goods == null){
			resp.setCode(201);
			resp.setMsg("该货号对应的商品不存在");
			return resp;
		}
		GoodsBo bo = goodsService.getGoods(warehouseId, positionType, goods.getGoodsId());
		resp.setResult(bo);
		if(bo==null){
			resp.setCode(201);
			resp.setMsg("该货号对应的商品不存在");
			return resp;
		}
		return resp;
	}
}
